<template>
	<view>
		<view class="gui-padding bg" :style="{background: imgServer ? 'url('+imgServer+'/yu2.jpg)' : ''}">
			<view class="gui-list-items"  @tap="info" @longpress="fu">
				<view class="gui-list-image ucenter-face gui-relative" style="margin-bottom: 15rpx;">
					<image class="gui-list-image ucenter-face-image" :src="avatarUrl" mode="widthFix"></image>
				</view>
			</view>
			<view class="" @tap="info" @longpress="fu" style="width: 690rpx;text-align: center;">
				<view class="gui-flex gui-align-items-center" style="margin: 0 auto;">
					<view class="gui-list-title-text gui-primary-color shenuser" style="width: 345rpx;text-align: right;">{{ user.name ? user.name : '商城用户' }}</view>
					<view v-if="user.shenfen == 0" class="shen">普通会员</view>
					<view v-if="user.shenfen == 1" class="shen">渠道商</view>
					<view v-if="user.shenfen == 2" class="shen">代理商</view>
				</view>
				<view class="gui-icons lizhili_hui gui-color-white gui-block-text" >&#xe69e; 我的编号： {{ user.user_no }}</view>
			</view>
		</view>

		<view class="ucenter-line"></view>
		<view style="padding: 15rpx 30rpx;">
			<view class="z-earnings gui-flex">
				<view class="z-left gui-flex" @tap="ear">
					<view class="z-left-l">
						<view class="z-money-title gui-color-white">我的收益(元)</view>
						<view style="color: #b9fe19;font-size: 36rpx; line-height: 1.4;">{{user.money}}</view>
					</view>
					<view class="z-left-r">
						<view class="z-money-title gui-color-white">总收益(元)</view>
						<view style="color: #07feee; font-size: 36rpx;line-height: 1.4;">{{user.money_zong}}</view>
					</view>
				</view>
				<view class="z-right" @tap="dep"><text>提现</text></view>
			</view>
		</view>

		<view class="ucenter-line"></view>
		<view class="gui-list gui-margin-top gui-padding">
			<view class="gui-list-items">
				<text class="gui-list-icon gui-icons gui-color-blue">&#xe60d;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title">
						<text class="gui-list-title-text">我的F码</text>
						<text class="gui-color-gray gui-text-small">{{ user.shang ? user.shang : '无F码' }}</text>
					</view>
				</view>
				<!-- <text class="gui-list-arrow-right gui-icons">&#xe601;</text> -->
			</view>
			<view class="gui-list-items" @tap="tui">
				<text class="gui-list-icon gui-icons gui-color-green">&#xe639;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">我的推广</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			<template v-if="user.shenfen==2 || user.shenfen==1">
			<view v-if="user.is_tuan==1" class="gui-list-items" @tap="tuan_index">
				<text class="gui-list-icon gui-icons gui-color-red" style="font-size: 50rpx;">&#xe611;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">代理商中心</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			<view v-else class="gui-list-items" @tap="tuan_shen">
				<text class="gui-list-icon gui-icons gui-color-red" style="font-size: 50rpx;">&#xe611;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">申请为代理商</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			</template>
			<view class="gui-list-items" @tap="tuan">
				<text class="gui-list-icon gui-icons gui-color-blue">&#xe63f;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">团购地址</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			<!-- #ifdef APP-PLUS -->
			<view class="gui-list-items" @tap="friend">
				<text class="gui-list-icon gui-icons gui-color-purple">&#xe625;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">邀请好友</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN -->
			<view class="gui-list-items">
				<text class="gui-list-icon gui-icons gui-color-purple">&#xe625;</text>
				<button open-type="share" style="width: 100%;margin-left: 10rpx;">
					<view class="gui-list-body gui-border-b" style="width: 100%;">
						<view class="gui-list-title"><text class="gui-list-title-text">邀请好友</text></view>
					</view>
				</button>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
			<!-- #endif -->
			<view class="gui-list-items" @tap="order">
				<text class="gui-list-icon gui-icons gui-color-orange">&#xe624;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title"><text class="gui-list-title-text">我的订单</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>

			<view class="gui-list-items" @tap="set">
				<text class="gui-list-icon gui-icons gui-color-yellow">&#xe613;</text>
				<view class="gui-list-body ">
					<view class="gui-list-title"><text class="gui-list-title-text">设置中心</text></view>
				</view>
				<text class="gui-list-arrow-right gui-icons">&#xe601;</text>
			</view>
		</view>
		<view class="ucenter-line"></view>

		<view class="" style="padding: 20rpx 0pt;">
			<view style="text-align: center;font-size: 25rpx;">
				<text class="path" @tap="tiao(4)">《服务协议》</text>
				和
				<text class="path" @tap="tiao(3)">《隐私政策》</text>
			</view>
			<view v-if="no" style="text-align: center;margin: 15rpx 0;font-size: 25rpx;">当前版本号：{{ no }}</view>
			<view style="text-align: center;margin: 15rpx 0;font-size: 25rpx;letter-spacing: 1px;">版权所有 {{ comp }}</view>
		</view>
	</view>
</template>
<script>
let common = require('@/common.js');

export default {
	data() {
		return {
			user: {},
			avatarUrl:'',
			imgServer: '',
			no: '',
			shield: {},
			comp: ''
		};
	},
	onLoad() {
		// #ifdef APP-PLUS
		this.no = plus.runtime.versionCode;
		// #endif
		this.imgServer = common.imgServer;
	},
	onShareAppMessage(res) {
		if (res.from === 'button') {
			// 来自页面内分享按钮
			console.log(res.target);
		}
		return {
			title: '欢迎使用商城',
			path: '/pages/my/login?yaoqing=' + this.user.user_no
		};
	},
	onShow() {
		uni.common.post(
			uni.common.apiServer + 'my',
			{
				type: 'get_my_info'
			},
			false,
			res => {
				if (res.code == 1) {
					if(res.data.avatarUrl){
						if(res.data.avatarUrl.substr(0,4)!='http'){
							this.avatarUrl=uni.common.imgServer+res.data.avatarUrl
						}else{
							this.avatarUrl=res.data.avatarUrl
						}
					}else{
						this.avatarUrl=uni.common.imgServer+'/yu2.jpg'
					}
					this.user = res.data
					this.comp = res.mall_config.shop_name
				} else {
					uni.showToast({
						icon: 'none',
						title: '尚未登陆，请登陆后购买'
					});
				}
			},
			e => {
				console.log(e);
			}
		);
		
	},
	methods: {
		
		fu() {
			uni.setClipboardData({
				data: this.user.user_no,
				success: function() {
					uni.common.msg('复制编号成功！');
				}
			});
		},
		ear: function() {
			uni.navigateTo({
				url: '/pages/my/earnings'
			});
		},
		dep: function() {
			uni.navigateTo({
				url: '/pages/my/deposit'
			});
		},
		logout() {
			uni.navigateTo({
				url: 'login'
			});
		},
		info() {
			uni.navigateTo({
				url: 'info'
			});
		},

		tui() {
			uni.navigateTo({
				url: 'tui'
			});
		},
		tuan_index() {
			if(this.user.is_tuan==1){
				uni.navigateTo({
					url: 'tuan/index'
				});
			}else{
				uni.common.msg('申请代理后操作！')
			}
		},
		tuan_shen() {
			if(this.user.is_tuan==-1){
				uni.navigateTo({
					url: 'tuan/shen'
				});
			}else{
				uni.common.msg('已经申请，无需重复申请！')
			}
		},
		tuan(){
			uni.navigateTo({
				url:'tuangou'
			})
		},
		friend() {
			uni.navigateTo({
				url: 'friend'
			});
		},
		order() {
			uni.navigateTo({
				url: 'order'
			});
		},
		set() {
			uni.navigateTo({
				url: 'set'
			});
		},
		tiao(type) {
			uni.navigateTo({
				url: '../index/web?src=' + type
			});
		}
	}
};
</script>
<style>
button::after {
	border: none;
}
button {
	background-color: transparent;
	padding-left: 0;
	padding-right: 0;
	line-height: inherit;
}
button {
	border-radius: 0;
}
.bg{
	padding-bottom: 30rpx;
	background-size: cover; 
	padding-top: 74rpx;
}
.jin {
	padding: 10px;
	background-color: #1e1e1e;
	border-radius: 15rpx 15rpx 0 0;
	color: #e6d19b;
}
.jin image {
	width: 10%;
	margin-right: 30rpx;
}
.jifen {
	width: 33%;
}
.xian {
	border-right: 1px solid #ececec;
	height: 60rpx;
}
.kuai {
	padding: 60rpx 10rpx 30rpx 10rpx;
	height: 50rpx;
}
.kuai .ti {
	line-height: 1.8;
}
.kuai .di {
	line-height: 1.3;
	color: #b6b6b6;
	font-size: 28rpx;
}
.specil image {
	width: 40rpx;
	margin-left: 20rpx;
	margin-right: 20rpx;
}
.ucenter-face {
	width: 140rpx;
	height: 140rpx;
}
.ucenter-face-image {
	width: 140rpx;
	height: 140rpx;
}
.ucenter-line {
	height: 20rpx;
	background-color: #f6f7f8;
	margin: 16rpx 0;
}
.logoff {
	line-height: 88rpx;
	font-size: 28rpx;
}
.gui-list-title-text {
	line-height: 60rpx;
}
.shenuser {
	font-size: 30rpx;
	padding: 4rpx 10rpx;
	color: #fff;
}
.shen {
	background-color: #ffa048;
	color: #ffffff;
	font-size: 25rpx;
	border-radius: 30rpx;
	padding: 4rpx 10rpx;
	display: inline-block;
	margin-left: 15rpx;
}
.lizhili_hui {
	color: #b6b6b6;
	line-height: 1.8;
	margin: 0 5rpx;
	font-size: 23rpx;
}

.z-earnings {
	background-image: linear-gradient(to right, #f15525, #e15324);
	padding: 15rpx;
	border-radius: 15rpx;
}
.z-left {
	width: ;
}
.z-left-l {
	width: 270rpx;
	border-right: 1rpx solid #fff;
	text-align: center;
}
.z-left-r {
	width: 270rpx;
	border-left: 1rpx solid #fff;
	text-align: center;
}
.z-money-title {
	font-size: 30rpx;
	margin-bottom: 20rpx;
}
.z-right {
	width: 120rpx;
	text-align: center;
	padding-top: 30rpx;
}
.z-right text {
	color: #ffffff;
	background-image: linear-gradient(to right, #d8b00e, #e19e0c);
	padding: 8rpx 16rpx;
	font-size: 30rpx;
	border-radius: 8rpx;
}
</style>
